<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>lambda test</title>
    <script src="../../js/jquery-3.4.1.js"></script>
</head>
<body>
<div class="modal fade" id="robot-audio-listen-modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">消息提醒：</h4>
            </div>
            <div class="modal-body">
                <audio hidden="hidden" src="" controls="controls" id="player">
                    <source type="audio/mpeg" />
                </audio>
                <audio src="" controls="controls" id="player2">
                    <source type="audio/mpeg" />
                </audio>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default pull-right" data-dismiss="modal" onclick="play1()">播放</button>
                <button type="button" class="btn btn-default pull-right" data-dismiss="modal" onclick="pause1()">暂停</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
</body>
<script>
    /* 如果在idea中, 需要设置languages&frameworks-> JavaScript-> 选择为EcmaScript6否则lambda语法会报错 */

    $(function () {
        const player = document.getElementById("player");
        player.load();
        $("#player").attr("src", "http://localhost/audio/listen3?pcmUrl=3f21f7a20d5711ea.pcm");
        $("#player2").attr("src", "http://localhost/audio/listen2?pcmFileName=3f21f7a20d5711ea.wav");

    })

    function pause1() {
        const player = document.getElementById("player");
        player.pause();
    }

    function play1() {
        const player = document.getElementById("player");
        player.play();
    }
</script>
</html>